﻿@using CMSMVC4
@using CMSMVC4.Filters
@model System.Data.DataTable
@if (Model != null)
{
    var db = new CMSMVC4Entities();
    for (var i = 0; i < Model.Rows.Count; i++)
    {
        var str = Convert.ToInt32(Model.Rows[i]["Id"].ToString());
        var data = db.Menus.Where(x => x.Area == MenuArea.Admin && x.Parrent == str).ToList();
        string clas = null;

        var color = "accordion-group color_" + (i + 2);
        var clas2 = "accordion-body collapse";

        if (Model.Rows[i]["Id"].ToString() == ViewBag.ID)
        {
            color = "accordion-group active color_" + (i + 2);
            clas2 = "accordion-body in collapse";
        }
        if (data.Count == 0)
        {
            clas = "dashboard";
        }
        if (data.Count > 0)
        {
            clas = "accordion-toggle";
        }
        
    <li class="@color" index="@Model.Rows[i]["Id"].ToString()">
        @if (data.Count == 0)
        {
            <a class="@clas" href="@Model.Rows[i]["Url"]">
                <img src="~/Content/template/img/menu_icons/dashboard.png" alt="">
                <span>@Model.Rows[i]["Name"].ToString()</span>
            </a>
        }

        @if (data.Count > 0)
        {
            <a class="@clas" data-toggle="collapse" data-parent="#sidebar_menu" href="#@i">
                <img src="~/Content/template/img/menu_icons/dashboard.png" alt="">
                <span>@Model.Rows[i]["Name"].ToString()</span>
            </a>
            <ul id="@i" class="@clas2">
                @{Html.RenderAction("ListLoadMenuChild", "Menus", new { area = "Admin", parrent = Model.Rows[i]["Id"].ToString() });}
            </ul>
        }
    </li>
    }
}

